/*
 * motorcontrol.h
 *
 *  Created on: 2025.5.27
 *      Author: TracyHenry
 */

#ifndef MOTORCONTROL_H_
#define MOTORCONTROL_H_
#include "FreeRTOS.h"
#include "task.h"
#include "stm32f1xx_hal.h"
#include "cmsis_os.h"
#include "gpio.h"
#include "timelist.h"

typedef enum MotorDirection{
    MotorPositive = 0,
    MotorNegative = 1
} MotorDirection;

typedef enum MotorAction{
    MotorAction_Stop = 0,
    MotorAction_Start = 1
} MotorAction;

extern uint8_t motorControl1Action;
extern uint8_t motorControl2Action;
extern uint8_t motorControl3Action;
extern uint8_t motorDirectionControl1Action;
extern uint8_t motorDirectionControl2Action;
extern uint8_t motorDirectionControl3Action;
extern uint8_t motorSpeedControl1Action;
extern uint8_t motorSpeedControl2Action;
extern uint8_t motorSpeedControl3Action;
extern uint8_t flagMotorControl1Update;
extern uint8_t flagMotorControl2Update;
extern uint8_t flagMotorControl3Update;
extern uint8_t flagTimeListUpdate;
void taskMotorControlInit(void);
void taskMotorControl(void const * argument);
void setAction(void);
void timeControl(void);
void taskMotorDirectionControl(uint8_t motorNum, MotorDirection direction);
void taskMotorActionControl(uint8_t motorNum, MotorAction action);
void sendudp(void);
void motorControlStart(TimeTableNode *found);
#endif /* MOTORCONTROL_H_ */
